<?php
/*
  [EWEISHOP] Copyright(C) 2017 Elinkint Inc.
  This is NOT a freeware, use is subject to license terms
   
  PaymentSecurity.php 2018-05-24 18:54 cunx $
   
*/

namespace common\library\wechat\payment;


use common\component\wechat\Wechat;
use common\library\wechat\WechatApi;

/**
 * 微信支付安全与风控
 * Class PaymentSecurity
 * @package common\library\wechat\payment
 * @author cunx
 */
class PaymentSecurity extends WechatApi
{
    static $apiType = 'payment';
    static $paymentId = 0;
    /**
     * 获取 RSA 公钥
     * -----------------------------------------------------
     * 1. 本接口将会得到 PKCS#1 格式密钥
     * 2. 使用 OpenSSL 可以转换 PKCS#1 为 PKCS#8 格式密钥
     *    openssl rsa -RSAPublicKey_in -in public.pem -out public.pem
     * -----------------------------------------------------
     * @return array|bool|void
     * @author cunx
     */
    public static function getPublicKey(){
        try{
            $result = self::getInstance()->security->getPublicKey();
            return $result['pub_key']??false;
        }catch(\Exception $result){}
        return Wechat::apiError($result);
    }
}